package com.juc.learn.lock;

/**
 * ClassName:TestLShareNumber
 * Package:com.juc.learn.lock
 * Description:
 *
 * @Author:@郭先森
 * @Create:2025/7/26 - 16:53
 * @Version:v1.0
 */
public class TestLShareNumber {
    public static void main(String[] args) {
        LShareNumber lShareNumber = new LShareNumber();

        new Thread(()->{
            while (true){
                try {
                    lShareNumber.add();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程一").start();

        new Thread(()->{
            while (true){
                try {
                    lShareNumber.sub();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程二").start();

        new Thread(()->{
            while (true){
                try {
                    lShareNumber.add();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程三").start();

        new Thread(()->{
            while (true){
                try {
                    lShareNumber.sub();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程四").start();

    }

}
